#!/usr/bin/env python

from __future__ import print_function
import random

def getRandOrigin():
	"""
	Returns an origin with x and y varying between -300 and 300, and z varying between 200 and 800
	"""
	# x and y
	origin = [ random.randint(-300, 300) for i in range(2) ]
	# z
	origin.append( random.randint(200, 800))
	return " ".join(str(i) for i in origin)	# convert to str, space separator

def getRandRadius(mu=50, sd=6):
	"""
	Returns a random radius with normal distribution 
	
	Defaults to mu=50, sd=6
	"""
	return str( int(random.normalvariate(mu, sd)) )		# truncate, then stringify

def getRandColor():
	"""
	Returns a random #RRGGBB color string
	"""
	color = [ random.randint(0, 255) for i in range(3) ]
	fmtstr = "".join("{0["+str(i)+"]:X}" for i in range(3))
	return "#" + fmtstr.format(color)

def getRandNormal():
	"""
	Returns a random normal out of 3^3 possibilities
	"""
	normal = [ random.randint(-1,1) for i in range(3) ]
	return " ".join(str(i) for i in normal)

def getRandDimensions(means=(50, 50, 50), sd=(10, 10, 10)):
	"""
	Returns random x y z dimensions

	Dimensions are distributed normally around x, y, z with default sd = 10
	"""
	dim = [ random.normalvariate(mu, sd) for mu, sd in zip(means, sd) ]
	return " ".join( str(int(i)) for i in dim )	# truncate

def printRandSphere(count):
	for i in range(count):
		print("Sphere {0} {1} {2}".format(getRandOrigin(), getRandRadius(), getRandColor()))

def printRandLight(count):
	for i in range(count):
		print("Light {0} {1} {2}".format(getRandOrigin(), getRandRadius(800, 30), getRandColor()))

def printRandDisc(count):
	for i in range(count):
		print("Disc {0} {1} {2} {3}".format(getRandNormal(), getRandOrigin(), getRandRadius(100, 20), getRandColor()))

def printRandBox(count):
	for i in range(count):
		print("Box {0} {1} {2}".format(getRandOrigin(), getRandDimensions(), getRandColor()))

if __name__ == "__main__":
	random.seed(None)
	printRandSphere(1)
	printRandDisc(1)
	printRandLight(1)
	printRandLight(1)
	printRandLight(1)
	print ("Scene 2")
	printRandBox(1)
	printRandLight(1)
	printRandLight(1)
	printRandLight(1)
